home *** CD-ROM | disk | FTP | other *** search
/ AI Game Programming Wisdom / AIGameProgrammingWisdom.iso / SourceCode / 02 Useful Techniques / 03 Orkin / ActionTable.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-08-20  |  1.5 KB  |  76 lines

  1. #ifndef ActionTable_H
  2. #define ActionTable_H
  3.  
  4. //
  5. // This is an optimized version of the ActionTable.
  6. // It uses one multimap rather than nested maps.
  7. //
  8.  
  9. #pragma warning(disable:4786)
  10. #include <Map>
  11.  
  12. #define MAX_PATH 80
  13.  
  14. #define CREATE_KEY(condition, action) (condition << 16) | action
  15.  
  16.  
  17. enum EnumAction
  18. {
  19.     kAct_Invalid    = -1,
  20.     kAct_Default    =  0,
  21.     kAct_Idle,
  22.     kAct_Walk,
  23.     kAct_Run,
  24.     kAct_Attack,
  25. };
  26.  
  27. enum EnumAnimCondition
  28. {
  29.     kACond_Invalid    = -1,
  30.     kACond_Default    =  0,
  31.     kACond_OneHanded,
  32.     kACond_TwoHanded,
  33.     kACond_Bow,
  34.     kACond_Staff,
  35. };
  36.  
  37. enum EnumActionDescriptor
  38. {
  39.     kADesc_Invalid    = -1,
  40.     kADesc_None        =  0,
  41.     kADesc_Swing,
  42.     kADesc_Jab,
  43. };
  44.  
  45. // --------------------------------------------------------------------------
  46.  
  47. struct ActionAnimInfoStruct
  48. {
  49.     char                    szAnimFileName[MAX_PATH];
  50.     EnumActionDescriptor    eActionDesc;
  51. };
  52.  
  53. // --------------------------------------------------------------------------
  54.  
  55. typedef    std::multimap<unsigned long, ActionAnimInfoStruct> CONDITION_ACTION_MAP;    // <ActionConditionKey, (szAnimFileName, eActionDesc)>
  56.  
  57. // --------------------------------------------------------------------------
  58.  
  59. class CActionTable {
  60.  
  61. public:
  62.     
  63.     void        Read(void);
  64.  
  65.     const char*    GetAnimation(EnumAnimCondition eAnimCond, EnumAction eAction, EnumActionDescriptor* peActionDesc);
  66.  
  67. protected:
  68.  
  69.     CONDITION_ACTION_MAP    m_condActionMap;
  70. };
  71.  
  72. // --------------------------------------------------------------------------
  73.  
  74. #endif // ActionTable_H
  75.  
  76.